﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using DataAccess.ArchivesTableAdapters;
using DataAccess;
using System.Data;

namespace BusinessLogic
{
    [DataObject]
    public class UserBO
    {
        private tblUsersTableAdapter UserAdapter = null;
        protected tblUsersTableAdapter Adapter
        {
            get
            {
                if (UserAdapter == null)
                {
                    UserAdapter = new tblUsersTableAdapter();
                }
                return UserAdapter;
            }
        }

        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public Archives.tblUsersDataTable GetAllUsers()
        {
            return Adapter.GetAllUsers();
        }

        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public DataTable GetByID(int uID)
        {
            return Adapter.GetByID(uID);
        }

        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public DataTable GetByAuthentication(string email, string password)
        {
            return Adapter.GetByAuthentication(email, password);
        }

        [DataObjectMethodAttribute(DataObjectMethodType.Update, true)]
        public int Update(global::System.Nullable<int> rID, string uFName, string uLName, string uPassword, string uEmail, global::System.Nullable<int> uPosition, global::System.Nullable<int> uDepartment, string uPhone, string uAddress, int uID)
        {
            return Adapter.UpdateUser(rID, uFName, uLName, uPassword, uEmail, uPosition, uDepartment, uPhone, uAddress, uID);
        }

        [DataObjectMethodAttribute(DataObjectMethodType.Insert, true)]
        public int AddNewUser(int rID, string uFName, string uLName, string uAddress, string uPhone, int uDepartment, string uPassword, string uEmail, int uPosition)
        {
            return Adapter.AddNewUser(rID, uFName, uLName, uAddress, uPhone
                                , uDepartment, uPosition, uEmail, uPassword);
        }

        [DataObjectMethodAttribute(DataObjectMethodType.Delete, true)]
        public int Delete(int uID)
        {
            return Adapter.DeleteUser(uID);
        }
    }
}
